﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using DatabaseSchemaReader;
using DatabaseSchemaReader.DataSchema;

namespace Happy.Edge.DatabaseSchemaReader.Extentions
{
    public static class DatabaseViewExtentions
    {
        public static object ToDynamic(this DatabaseView view)
        {
            return new
            {
                name = view.Name,
                isPlural = Utils.IsPlural(view.Name),
                isSingular = Utils.IsSingular(view.Name),
                plural = Utils.Pluralize(view.Name),
                singular = Utils.Singularize(view.Name),
                owner = view.SchemaOwner,
                columns = view.Columns.Select(column => column.ToDynamic()).ToList()
            };
        }
    }
}
